package sdk.service;

import model.Dossier;
import model.Emp;
import util.Page;
import dao.DossierDAO;
import dao.impl.DossierDAOImpl;
import dao.impl.EmpDAOImpl;

public class DossierManagerService {
	DossierDAO dossierDAO = new DossierDAOImpl();

	public Page<Dossier> getAllDossier(int pageNo, int pageSize) {
		return dossierDAO.getAllDossier(pageNo, pageSize);
	}

	public Dossier getById(int id) {
		return dossierDAO.getById(id);
	}

	public Dossier getByDosNo(String dosno) {
		return dossierDAO.getByDosNo(dosno);
	}

	public Page<Dossier> getByDossierName(int pageNo, int pageSize, String name) {
		return dossierDAO.getByDossierName(pageNo, pageSize, name);
	}

	public Page<Dossier> getByEmp(int pageNo, int pageSize, Emp emp) {
		return dossierDAO.getByEmp(pageNo, pageSize, emp);
	}

	public Page<Dossier> getByEmp(int pageNo, int pageSize, String empName) {
		return dossierDAO.getByEmp(pageNo, pageSize, empName);
	}

	public Page<Dossier> getByEmp(int pageNo, int pageSize, int empid) {
		return dossierDAO.getByEmp(pageNo, pageSize, empid);
	}

	public boolean addDossier(String dosno, int empid, String dosname,
			String synopsis, String remark) {
		Dossier dossier = new Dossier();

		dossier.setDosno(dosno);
		dossier.setEmp(new EmpDAOImpl().getEmpById(empid));
		dossier.setName(dosname);
		dossier.setSynopsis(synopsis);
		dossier.setRemark(remark);
		return dossierDAO.addDossier(dossier);
	}

	public boolean updateDossier(int id, String dosno, int empid,
			String dosname, String synopsis, String remark) {
		Dossier dossier = new Dossier();
		dossier.setId(id);
		dossier.setDosno(dosno);
		dossier.setEmp(new EmpDAOImpl().getEmpById(empid));
		dossier.setName(dosname);
		dossier.setSynopsis(synopsis);
		dossier.setRemark(remark);

		return dossierDAO.updateDossier(dossier);
	}

	public boolean deleteDossier(Dossier Dossier) {
		return dossierDAO.deleteDossier(Dossier);
	}

	public boolean deleteById(int id) {
		return dossierDAO.deleteById(id);
	}

	public boolean deleteByDosNo(String dosno) {
		return dossierDAO.deleteByDosNo(dosno);
	}

	public boolean deteteByEmpId(int empid) {
		return dossierDAO.deteteByEmpId(empid);
	}
}
